def is_prime(n):
    if n < 2:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True

def nearest_prime(n):
    if n < 2:
        return None
    i = n
    while True:
        if is_prime(i):
            return i
        i += 1
    return None

def convert_to_number(words):
    num_dict = {
        'zero': 0, 'one': 1, 'two': 2, 'three': 3, 'four': 4,
        'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9
    }
    num = 0
    for word in words:
        num = num * 10 + num_dict[word]
    return num

input_words = input("Введите три слова, разделенных пробелом: ").split()

if len(input_words) != 3:
    print("Wrong input")
else:
    try:
        num = convert_to_number(input_words)
        if num < 100 or num >= 1000:
            print("Wrong input")
        else:
            nearest = nearest_prime(num)
            print(nearest)
    except KeyError:
        print("Wrong input")
